<?php
defined('SWAP_ROOT') or die('非法操作');
//---------------------------------插件配置部分--------------------------------------
function cd_sfyz_config(){
$config['swap_plug']='实名认证';
$config['swap_plug_version']='1.0';
$config['swap_plug_explain']=<<<SWAP
用于SWAPIDC的找回密码操作,以防止用户无法找回自己的帐号
SWAP;
$config['swap_plug_author']='CcDalao';
$config['swap_plug_website']='http://blog.ccdalao.cn/';
return $config;
}
//------------------------------------------------------------------------------------
function cd_sfyz_template(){
	$lang=plug_lang_get('cd_sfyz','index');
	echo '<li><a href="/index.php/plugin/cd_sfyz/index/"><i class="icon-cog"></i>实名认证</a></li>';
}

function cd_sfyzs_template(){
	$lang=plug_lang_get('cd_sfyz','index');
	$uid = User::Uid();
    $url = '//'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
    $key = 'cart';  

    if (strpos($url, $key) == true) { 
            if(empty($uid)){
      exit(header('Location://'.$_SERVER['HTTP_HOST'].'/index.php/index/login/?error=请先登陆方可购买！'));
    }else{
      $CD_sfyz_sql_pd = D()->query("select * from 用户实名认证插件 where uid={$uid}");
      $CD_sfyz_sql_pd_fatch = D()->fetch_assoc();

      if(empty($CD_sfyz_sql_pd_fatch)){
        exit(header('Location://'.$_SERVER['HTTP_HOST'].'/index.php/plugin/cd_sfyz/index/?error=请先进行实名认证'));
      }elseif ($CD_sfyz_sql_pd_fatch['open'] != 1) {
        exit(header('Location://'.$_SERVER['HTTP_HOST'].'/index.php/plugin/cd_sfyz/index/?error=请先进行实名认证'));
      }
    } 
    }



}

add_swap_plug('用户页面列表','cd_sfyz_template');
add_swap_plug("HEAD区域","cd_sfyzs_template");
function cd_sfyzc_template(&$array){
		$array[]=array('name'=>'实名认证插件设置','link'=>'/index.php/plugin/cd_sfyz/set/');
}
function cd_sfyzd_template(&$array){
		$array[]=array('name'=>'实名认证信息列表','link'=>'/index.php/plugin/cd_sfyz/lists/');
}
add_swap_plug('管理员菜单列表','cd_sfyzc_template');
add_swap_plug('管理员菜单列表','cd_sfyzd_template');

